home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group01b.txt
/
000163_icon-group-sender_Tue Oct 30 16:51:46 2001.msg
< prev
next >
Wrap
Internet Message Format
|
2002-01-03
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id f9UNpeE13236
for icon-group-addresses; Tue, 30 Oct 2001 16:51:40 -0700 (MST)
Message-Id: <200110302351.f9UNpeE13236@baskerville.CS.Arizona.EDU>
From: Chris.D.Tenaglia@jci.com
Subject: Trick or Treat?
To: icon-group@cs.arizona.edu
Date: Tue, 30 Oct 2001 13:25:30 -0600
X-MIMETrack: Serialize by Router on jwimkrs1.na.jci.com/NA/Johnson_Controls(Release 5.07a
|May 14, 2001) at 10/30/2001 03:13:05 PM
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 2581
Code snippits for 10/31/2001. Ever wish you had a time machine?
I did. Here are two samples. yesterday returns yesterday's date
and tomorrow returns tomorrows date. So simple, so useful.
--------------
#
# file : yesterday.icn
# desc : generate yesterday's date mm/dd/yy
# use : call from scripts etc,... avoid today!
#
# update by what
# 30-oct-2001 tenaglia initial write
#
procedure main()
last := table()
last["01"] := 31
last["02"] := 28
last["03"] := 31
last["04"] := 30
last["05"] := 31
last["06"] := 30
last["07"] := 31
last["08"] := 31
last["09"] := 30
last["10"] := 31
last["11"] := 30
last["12"] := 31
last["-1"] := 31
field := parse(&date,'/')
year := field[1]
yy := year[3:0]
mm := field[2]
dd := field[3]
if (year % 4) = 0 then last["02"] := 29
dd -:= 1
if dd < 1 then
{
mm -:= 1
dd := last[right(mm,2,0)]
if mm < 1 then
{
yy -:= 1
mm := 12
}
}
result := right(mm,2,0) || "/" ||
right(dd,2,0) || "/" ||
right(yy,2,0)
write(result)
end
#
# parse a string into a list with respect to a delimiter
#
procedure parse(line,delims)
static chars
chars := &cset -- delims
tokens := []
line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
return tokens
end
------------------------------------
#
# file : tomorrow.icn
# desc : generate tomorrow's date mm/dd/yy
# use : call from scripts etc,... avoid today!
#
# update by what
# 30-oct-2001 tenaglia initial write
#
procedure main()
last := table()
last["01"] := 31
last["02"] := 28
last["03"] := 31
last["04"] := 30
last["05"] := 31
last["06"] := 30
last["07"] := 31
last["08"] := 31
last["09"] := 30
last["10"] := 31
last["11"] := 30
last["12"] := 31
last["0"] := 31
last["13"] := 31
field := parse(&date,'/')
year := field[1]
yy := year[3:0]
mm := field[2]
dd := field[3]
if (year % 4) = 0 then last["02"] := 29
dd +:= 1
if dd > last[mm] then
{
mm +:= 1
dd := "01"
if mm > 12 then
{
yy +:= 1
mm := "01"
}
}
result := right(mm,2,0) || "/" ||
right(dd,2,0) || "/" ||
right(yy,2,0)
write(result)
end
#
# parse a string into a list with respect to a delimiter
#
procedure parse(line,delims)
static chars
chars := &cset -- delims
tokens := []
line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
return tokens
end
--------------------------------
Chris Tenaglia, technical analyst, Johnson Controls